package com.botarena.client.ui;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class GenericDialogBox extends DialogBox {
	
	private Label labelMessage;
	
	public GenericDialogBox(String title) {
		this(title, "");
	}
	
	public GenericDialogBox(String title, String message) {
		// Set the dialog box's caption.
		setText(title);
		// Enable animation.
		setAnimationEnabled(true);
		// Enable glass background.
		setGlassEnabled(true);
		setAutoHideEnabled(true);
		
		Panel panel = new VerticalPanel();
		
		labelMessage = new Label(message);
		panel.add(labelMessage);
		
		Button buttonOK = new Button("OK");
		buttonOK.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				GenericDialogBox.this.hide();
			}
		});
		panel.add(buttonOK);
		
		setWidget(panel);
	}
	
	public void setMessage(String message) {
		labelMessage.setText(message);
	}
}
